#ifndef _core_dispatch_exception_hpp_
#define _core_dispatch_exception_hpp_

/** \file exception.hpp
 *  \author Adrian Schweizer
 *  \created  $Sa 18 Aug 03:48:01 pm CEST 2007 schwadri@SchwadriComp.local$
 *  \modified $So 19 Aug 03:52:05 pm CEST 2007 schwadri@SchwadriComp.local$
 */

#include <exception>

namespace core {

    namespace dispatch {

        /** \brief this exception is thrown if the key validation failed*/
        template <typename Key>
            struct invalid_key : std::exception {
                invalid_key () : std::exception (), key () { };
                invalid_key (const Key & k) : std::exception(), key(k) { };

                ~invalid_key() throw () { };

                const char * what() const throw () {
                    return "dispatch: invalid key passed.";
                };

                Key key; ///< the key that caused the exception
            };

        /** \brief exception for valid keys that have no handler*/
        template <typename Key>
            struct unhandled_key : std::exception {
                unhandled_key () : std::exception (), key () { };
                unhandled_key (const Key & k) : std::exception(), key(k) { };

                ~unhandled_key() throw () { };

                const char * what() const throw () {
                    return "dispatch: no handler for this key.";
                };

                Key key; ///< the key that caused the exception
            };
    } // namespace dispatch
} // namespace core

#endif // _core_dispatch_exception_hpp_
